//
//  ResignViewController.m
//  Vpay
//
//  Created by 伟大大 on 2018/9/15.
//  Copyright © 2018年 丁伟佳. All rights reserved.
//

#import "ResignViewController.h"
#import "UILabel+StringFrame.h"
#import "ResignTableViewCell.h"
#import "WKVerCodeImageView.h"
@interface ResignViewController () {
    CGSize titleSize;
    NSString *str;

}
@property (nonatomic, strong) WKVerCodeImageView *codeImageView;

@property (nonatomic, strong) NSIndexPath *selectPath; //存放被点击的哪一行的标志
@end

@implementation ResignViewController

#pragma mark -
#pragma lifeCircle
#pragma mark -
- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    //    rightNavBtn.hidden = NO;
    
    //    self.navigationController.navigationBar.barTintColor = RGBCOLOR(255, 255, 255);
//    [theApp hiddenBottomView];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //    [theApp showBottomView];
    //    rightNavBtn.hidden = YES;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    //    self.navigationController.navigationBar.barTintColor = RGBCOLOR(255, 255, 255);
    
    
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view = [[[NSBundle mainBundle]loadNibNamed:@"ResignViewController" owner:self options:nil]lastObject];
    
    self.title = @"注册";
    [self.navigationController.navigationBar setTitleTextAttributes:
     
     @{NSFontAttributeName:[UIFont systemFontOfSize:17],
       
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    [self initData];
    [self initNavBtns];
    [self initViews];
    
    
    [NSThread detachNewThreadSelector:@selector(requestCountryData) toTarget:self withObject:nil];
    // Do any additional setup after loading the view from its nib.
}
- (void)initData {
    self.array = [NSMutableArray array];
}
- (void)initNavBtns {
    
    self.navigationItem.leftBarButtonItem = [AppUtility getNavBtnItemLefBacktWith:@selector(leftNavBtnClicked) andTarget:self];
}
- (void)leftNavBtnClicked {
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)requestCountryData
{
    
    NSDictionary *resultDict_hot =[NetUtility getDataWithURLStr:[NSString stringWithFormat:@"%@",KURLCountry] andPostStr:nil];
    
    UEXNSLog(@"URL = %@ ,resultDict_hot=%@",KURLCountry,resultDict_hot);
    
    if ([[resultDict_hot objectForKey:@"s"] intValue]==1) {
        
        [self.array removeAllObjects];
        
        [self.array addObjectsFromArray:[resultDict_hot objectForKey:@"d"]];
        
        
    }
    
        [self performSelectorOnMainThread:@selector(RefreshView) withObject:nil waitUntilDone:NO];
    
}
- (void)RefreshView {
    [_Country_tableView reloadData];
}
- (void)initViews {
    
    self.YQM_textfiled.delegate = self;
    self.Nickname_textfiled.delegate = self;
    self.Phone_textfiled.delegate = self;
    self.Password_textfiled.delegate = self;
    self.Pay_textfiled.delegate = self;
    self.YZM_textfiled.delegate = self;
    
    [self.Password_textfiled addTarget:self action:@selector(textFiledDidChange:) forControlEvents:UIControlEventAllEvents];
    [self.Pay_textfiled addTarget:self action:@selector(textFiledDidChange1:) forControlEvents:UIControlEventAllEvents];
    [self.Pay_textfiled addTarget:self action:@selector(textFiledDidChange2:) forControlEvents:UIControlEventAllEvents];

    self.MidView.layer.masksToBounds = YES;
    self.MidView.userInteractionEnabled = YES;
    self.MidView.layer.cornerRadius = 4.5;
    
    self.AlphaView.userInteractionEnabled = YES;
    
    self.Country_tableView.userInteractionEnabled = YES;
    self.Country_tableView.delegate = self;
    self.Country_tableView.dataSource = self;
    self.Country_tableView.rowHeight = 35*theApp.autoSizeScaleY;
    self.Country_tableView.backgroundColor = BACKCOLOR;
    self.Country_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    self.YQMlabel.text = NSLocalizedString(@"yqm", nil);
    self.Nickname_label.text = NSLocalizedString(@"nicheng", nil);
    self.Phonenum_label.text = NSLocalizedString(@"phonenum", nil);
    self.Password_label.text = NSLocalizedString(@"confirmpass", nil);
    self.ZFpass_label.text = NSLocalizedString(@"zfpass", nil);
    self.YZM_label.text = NSLocalizedString(@"yzm", nil);
    
    self.YQM_textfiled.placeholder = NSLocalizedString(@"yqmtextfiled", nil);
    self.Nickname_textfiled.placeholder = NSLocalizedString(@"nctextfiled", nil);
    self.Phone_textfiled.placeholder = NSLocalizedString(@"phonetextfiled", nil);
    self.Password_textfiled.placeholder = NSLocalizedString(@"passtextfiled", nil);
    self.Pay_textfiled.placeholder = NSLocalizedString(@"zftextfiled", nil);
    self.YZM_textfiled.placeholder = NSLocalizedString(@"yzmtextfiled", nil);
    
    [self.HQYZ_btn setTitle:NSLocalizedString(@"getcode", nil) forState:UIControlStateNormal];
    [self.Confirm_btn setTitle:NSLocalizedString(@"tj", nil) forState:UIControlStateNormal];

    if (([[[NSUserDefaults standardUserDefaults] objectForKey:@"myLanguage"] isEqualToString:@"zh-Hans"] && ![[[NSUserDefaults standardUserDefaults] objectForKey:@"myLanguage"] isEqualToString:@""])||![[NSUserDefaults standardUserDefaults] objectForKey:@"myLanguage"]) {
        
    }else {
        
        [self.YQMlabel setFrame:CGRectMake(self.YQMlabel.frame.origin.x, 10*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.YQMlabel.frame.size.height)];
        [self.YQM_textfiled setFrame:CGRectMake(self.YQMlabel.frame.origin.x, self.YQMlabel.frame.origin.y+self.YQMlabel.frame.size.height+5*theApp.autoSizeScaleY, 300*theApp.autoSizeScaleX, self.YQM_textfiled.frame.size.height)];
        [self.spliteView1 setFrame:CGRectMake(self.spliteView1.frame.origin.x, self.YQM_textfiled.frame.size.height+self.YQM_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView1.frame.size.width, self.spliteView1.frame.size.height)];
        
        [self.Nickname_label setFrame:CGRectMake(self.Nickname_label.frame.origin.x, self.spliteView1.frame.origin.y+6*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.Nickname_label.frame.size.height)];
        [self.Nickname_textfiled setFrame:CGRectMake(self.Nickname_label.frame.origin.x, self.Nickname_label.frame.origin.y+self.Nickname_label.frame.size.height+5*theApp.autoSizeScaleY, self.Nickname_label.frame.size.width, self.Nickname_textfiled.frame.size.height)];
        [self.spliteView2 setFrame:CGRectMake(self.spliteView2.frame.origin.x, self.Nickname_textfiled.frame.size.height+self.Nickname_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView2.frame.size.width, self.spliteView2.frame.size.height)];
        
        [self.Phonenum_label setFrame:CGRectMake(self.Phonenum_label.frame.origin.x, self.spliteView2.frame.origin.y+6*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.Phonenum_label.frame.size.height)];
        
//        self.Area_label.text = @"+86";
//        titleSize = [self.Area_label boundingRectWithSize:CGSizeMake(0, self.Area_label.frame.size.height)];
//        SLog(@"titlesize.width = %f",titleSize.width);
        
        [self.Area_btn setFrame:CGRectMake(self.Phonenum_label.frame.origin.x, self.Phonenum_label.frame.origin.y+self.Phonenum_label.frame.size.height+7*theApp.autoSizeScaleY, titleSize.width+10*theApp.autoSizeScaleX, self.Area_btn.frame.size.height)];
        
        [self.spliteView7 setFrame:CGRectMake(self.Area_label.frame.origin.x+titleSize.width+15*theApp.autoSizeScaleX, self.Phonenum_label.frame.size.height+self.Phonenum_label.frame.origin.y+6*theApp.autoSizeScaleY, self.spliteView7.frame.size.width, 15*theApp.autoSizeScaleY)];

        [self.Phone_textfiled setFrame:CGRectMake(self.spliteView7.frame.origin.x+9*theApp.autoSizeScaleX, self.Phonenum_label.frame.origin.y+self.Phonenum_label.frame.size.height+5*theApp.autoSizeScaleY, self.Phone_textfiled.frame.size.width, self.Phone_textfiled.frame.size.height)];
        [self.spliteView3 setFrame:CGRectMake(self.spliteView3.frame.origin.x, self.Phone_textfiled.frame.size.height+self.Phone_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView3.frame.size.width, self.spliteView3.frame.size.height)];
        
        [self.Password_label setFrame:CGRectMake(self.Password_label.frame.origin.x, self.spliteView3.frame.origin.y+6*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.Password_label.frame.size.height)]; 
        [self.Password_textfiled setFrame:CGRectMake(self.Password_label.frame.origin.x, self.Password_label.frame.origin.y+self.Password_label.frame.size.height+5*theApp.autoSizeScaleY, 340*theApp.autoSizeScaleY, self.Password_textfiled.frame.size.height)];
        [self.spliteView4 setFrame:CGRectMake(self.spliteView4.frame.origin.x, self.Password_textfiled.frame.size.height+self.Password_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView4.frame.size.width, self.spliteView4.frame.size.height)];
        
        [self.ZFpass_label setFrame:CGRectMake(self.ZFpass_label.frame.origin.x, self.spliteView4.frame.origin.y+6*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.ZFpass_label.frame.size.height)];
        [self.Pay_textfiled setFrame:CGRectMake(self.ZFpass_label.frame.origin.x, self.ZFpass_label.frame.origin.y+self.ZFpass_label.frame.size.height+5*theApp.autoSizeScaleY, 300*theApp.autoSizeScaleY, self.Pay_textfiled.frame.size.height)];
        [self.spliteView5 setFrame:CGRectMake(self.spliteView5.frame.origin.x, self.Pay_textfiled.frame.size.height+self.Pay_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView5.frame.size.width, self.spliteView5.frame.size.height)];
        
        [self.YZM_label setFrame:CGRectMake(self.YZM_label.frame.origin.x, self.spliteView5.frame.origin.y+6*theApp.autoSizeScaleY, 150*theApp.autoSizeScaleY, self.YZM_label.frame.size.height)];
        [self.YZM_textfiled setFrame:CGRectMake(self.YZM_label.frame.origin.x, self.YZM_label.frame.origin.y+self.YZM_label.frame.size.height+5*theApp.autoSizeScaleY, 300*theApp.autoSizeScaleY, self.YZM_textfiled.frame.size.height)];
        [self.spliteView6 setFrame:CGRectMake(self.spliteView6.frame.origin.x, self.YZM_textfiled.frame.size.height+self.YZM_textfiled.frame.origin.y+1*theApp.autoSizeScaleY, self.spliteView6.frame.size.width, self.spliteView6.frame.size.height)];
        
        
        [self.HQYZ_btn setFrame:CGRectMake(self.HQYZ_btn.frame.origin.x, self.YZM_textfiled.frame.origin.y-5*theApp.autoSizeScaleY, self.HQYZ_btn.frame.size.width, self.HQYZ_btn.frame.size.height)];
        [self.Confirm_btn setFrame:CGRectMake(self.Confirm_btn.frame.origin.x, 330*theApp.autoSizeScaleY, self.Confirm_btn.frame.size.width, self.Confirm_btn.frame.size.height)];
        
        
        
    }

    if (isTimer!=0)
    {
        
        [self.HQYZ_btn setTitle:[NSString stringWithFormat:@"%d%@",isTimer,NSLocalizedString(@"freget", nil)] forState:UIControlStateNormal];
        self.HQYZ_btn.userInteractionEnabled = NO;
        
        [countDownTimer invalidate];
        countDownTimer = nil;
        countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
        
        
        
    }
    else
    {
        [self.HQYZ_btn setTitle:NSLocalizedString(@"getcode", nil) forState:UIControlStateNormal];
    }
    
    [self.HQYZ_btn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    //        [_yanZhengBtn setBackgroundColor:TITLECOLOR];
    [self.HQYZ_btn setTitleColor:RGBCOLOR(255, 0, 0) forState:UIControlStateNormal];
    
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouched)];
    //    tap.delegate = self;
    tap1.delegate = self;
    tap1.numberOfTouchesRequired = 1;
    [self.TopView addGestureRecognizer:tap1];
    
    _codeImageView = [[WKVerCodeImageView alloc] initWithFrame:CGRectMake([AppUtility screenWidth]-10*theApp.autoSizeScaleX-80*theApp.autoSizeScaleX, 215*theApp.autoSizeScaleY, 70*theApp.autoSizeScaleX, 25*theApp.autoSizeScaleY)];
    _codeImageView.hidden = YES;
    _codeImageView.bolck = ^(NSString *imageCodeStr){//看情况是否需要
        NSLog(@"imageCodeStr = %@",imageCodeStr);
        str=[NSString stringWithFormat:@"%@", imageCodeStr];
    };
    //是否需要斜体
    _codeImageView.isRotation = YES;
    [_codeImageView freshVerCode];
    
    

    
    //点击刷新
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
    [_codeImageView addGestureRecognizer:tap];
    
    [self.TopView addSubview: _codeImageView];
    [self.TopView addSubview:self.AlphaView];
    [self.AlphaView addSubview:self.MidView];
    [self.MidView addSubview:self.Country_tableView];
    
}
- (void)tapClick:(UITapGestureRecognizer*)tap
{
    [_codeImageView freshVerCode];
    
}
-(void)timerFired
{
    if (isTimer!=0) {
        
        isTimer--;

        [self.HQYZ_btn setTitle:[NSString stringWithFormat:@"%d%@",isTimer,NSLocalizedString(@"freget", nil)] forState:UIControlStateNormal];
        
    }
    else
    {
        [countDownTimer invalidate];
        [self.HQYZ_btn setTitle:NSLocalizedString(@"getcode", nil) forState:UIControlStateNormal];
        self.HQYZ_btn.userInteractionEnabled = YES;
    }
}

-(void)tapTouched{
    
    if ([_YQM_textfiled isFirstResponder]) {
        [_YQM_textfiled resignFirstResponder];
    }
    if ([_Phone_textfiled isFirstResponder]) {
        [_Phone_textfiled resignFirstResponder];
    }
    if ([_Nickname_textfiled isFirstResponder]) {
        [_Nickname_textfiled resignFirstResponder];
    }
    if ([_Password_textfiled isFirstResponder]) {
        [_Password_textfiled resignFirstResponder];
    }
    if ([_Pay_textfiled isFirstResponder]) {
        [_Pay_textfiled resignFirstResponder];
    }
    if ([_YZM_textfiled isFirstResponder]) {
        [_YZM_textfiled resignFirstResponder];
    }
    if ([_TX_textfiled isFirstResponder]) {
        [_TX_textfiled resignFirstResponder];
    }
    
    
}

- (void)textFiledDidChange:(UITextField *)textfiled {
    
    if (self.Password_textfiled.text.length > 32) {
        //提示语
//        [self showMessage:@"输入限制20个字符以内"];
        //截取
        self.Password_textfiled.text = [textfiled.text substringToIndex:20];
    }
}
- (void)textFiledDidChange1:(UITextField *)textfiled {
    
    if (self.Pay_textfiled.text.length > 6) {
        //提示语
        //        [self showMessage:@"输入限制20个字符以内"];
        //截取
        self.Pay_textfiled.text = [textfiled.text substringToIndex:6];
    }
}
- (void)textFiledDidChange2:(UITextField *)textfiled {
    
    if (self.YZM_textfiled.text.length > 6) {
        //提示语
        //        [self showMessage:@"输入限制20个字符以内"];
        //截取
        self.YZM_textfiled.text = [textfiled.text substringToIndex:6];
    }
}
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    if ([string isEqualToString:@"\n"]) {
        [textField resignFirstResponder];
        return NO;
    }
    
    
    //        if (textField==self.YHtextfiled) {
    //
    //
    //            return [AppUtility validateNumber:string];
    //        }
    //        else{
    //
    //            return YES;
    //        }
    return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
    
//    NSString *postStr = [NSString stringWithFormat:@"%@&uname=%@",KURLCheckYHM,_YHtextfiled.text];
//
//
//    NSDictionary *resultDict = [NetUtility getDataWithURLStr:postStr andPostStr:nil];
//
//    //    NSDictionary *resultDict =[NetUtility getDataWithURLStr:[NSString stringWithFormat:@"%@%@",KURLRegister,postStr] andPostStr:nil andView:self.navigationController.view];
//
//
//    UEXNSLog(@"URL---==%@%@ kURLRegister dict=%@",KURLCheckYHM,postStr,resultDict);
//
//
//    if (resultDict) {
//        int status = [[resultDict objectForKey:@"code"] intValue];
//
//
//        if (status==200) {
//
//            [self.navigationController.view makeToast:[[resultDict objectForKey:@"datas"] objectForKey:@"message"] ];
//
//            [self.navigationController popViewControllerAnimated:YES];
//
//
//        }else {
//            [self.navigationController.view makeToast:[[resultDict objectForKey:@"datas"] objectForKey:@"error"] ];
//            textField.text = @"";
//
//        }
//    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


- (IBAction)HQYZ_btnClik:(UIButton *)sender {
    [self.Phone_textfiled resignFirstResponder];
//    if (![AppUtility checkTel:self.Phone_textfiled.text]) {
//
//        return;
//    }
    if ([AppUtility isBlankString:_Phone_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"mobilets", nil)];
        return;
    }
    self.TX_label.hidden = NO;
    self.TX_textfiled.hidden = NO;
    _codeImageView.hidden = NO;
    _spliteView8.hidden = NO;
    
    if ([AppUtility isBlankString:_TX_textfiled.text]) {
        [self.view makeToast:@"请填写图形验证码"];
        return;
    }
    
    BOOL result1 =  [_TX_textfiled.text compare:str
                                        options:NSCaseInsensitiveSearch | NSNumericSearch]==NSOrderedSame;
    
    if (result1) {
        NSLog(@"succes");
    }else{
        [self.view makeToast:@"验证码输入错误"];
        return;
    }
    NSString *postStr = [NSString stringWithFormat:@"&mobile=%@",_Phone_textfiled.text];
    
    NSDictionary *resultDict = [NetUtility getDataWithURLStr:KURLSendSMS andPostStr:postStr];
    
    UEXNSLog(@"URL====%@==== resultDict=%@",[NSString stringWithFormat:@"%@mobile=%@",KURLSendSMS,self.Phone_textfiled.text],resultDict);
    
    if ([[resultDict objectForKey:@"s"]intValue] == 1) {
        
        [self.HQYZ_btn setTitle:@"60秒" forState:UIControlStateNormal];
        isTimer = 60;
        self.HQYZ_btn.userInteractionEnabled = NO;
        
        
        countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
        [self.view makeToast:[resultDict objectForKey:@"i"]];
        
    }else {
        [self.view makeToast:[resultDict objectForKey:@"i"]];
        
    }
}

- (IBAction)TJ_btnClik:(UIButton *)sender {
    //注册
    
//    if ([AppUtility isBlankString:_YQM_textfiled.text]||[AppUtility isBlankString:_Nickname_textfiled.text]||[AppUtility isBlankString:_Phone_textfiled.text]||[AppUtility isBlankString:_Password_textfiled.text]||[AppUtility isBlankString:_Pay_textfiled.text]||[AppUtility isBlankString:_YZM_textfiled.text])
//    {
//
//        [self.view makeToast:@"请完善信息"];
//
//        return;
//    }
    if ([AppUtility isBlankString:_YQM_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"zcyqmts", nil)];
        return;
    }
    if ([AppUtility isBlankString:_Nickname_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"ncts", nil)];
        return;
        
    }
    if ([AppUtility isBlankString:_Phone_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"mobilets", nil)];
        return;
    }
    if ([AppUtility isBlankString:_Password_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"delmmts", nil)];
        return;
    }
    if ([_Password_textfiled.text length]<6) {
        
        [self.view makeToast:NSLocalizedString(@"delmmnumts", nil)];
        return;
        
    }
    if (![AppUtility judgePassWordLegal:_Password_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"delmmzmts", nil)];
        return;
    }
    if ([AppUtility isBlankString:_Pay_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"zfmmts", nil)];
        return;
    }
    if ([_Pay_textfiled.text length]<6) {
        [self.view makeToast:NSLocalizedString(@"zfmmnumts", nil)];
        return;
    }
    if ([AppUtility isBlankString:_YZM_textfiled.text]) {
        [self.view makeToast:NSLocalizedString(@"messagets", nil)];
        return;
    }
//    NSString *number =_Phone_textfiled.text;
//    if (![AppUtility checkTel:number]) {
//        return;
//    }
//
    
   
//    if ([_Password_textfiled.text length]>32) {
//        [self.view makeToast:@"请输入少于32位的密码"];
//        return;
//    }

    BOOL result1 =  [_TX_textfiled.text compare:str
                                         options:NSCaseInsensitiveSearch | NSNumericSearch]==NSOrderedSame;
    
    if (result1) {
        NSLog(@"succes");
    }else{
        [self.view makeToast:@"验证码输入错误"];
        return;
    }
    

    NSString *postStr = [NSString stringWithFormat:@"pid=%@&username=%@&mobile=%@&login_pwd=%@&safety_pwd=%@&code=%@",_YQM_textfiled.text,_Nickname_textfiled.text,_Phone_textfiled.text,_Password_textfiled.text,_Pay_textfiled.text,_YZM_textfiled.text];


    NSDictionary *resultDict = [NetUtility getDataWithURLStr:KURLRegister andPostStr:postStr];

    //    NSDictionary *resultDict =[NetUtility getDataWithURLStr:[NSString stringWithFormat:@"%@%@",KURLRegister,postStr] andPostStr:nil andView:self.navigationController.view];


    UEXNSLog(@"URL---==%@%@ kURLRegister dict=%@",KURLRegister,postStr,resultDict);


    if (resultDict) {
        int status = [[resultDict objectForKey:@"code"] intValue];


        if (status==1) {

            [self.navigationController.view makeToast:[resultDict objectForKey:@"i"]];

            [self.navigationController popViewControllerAnimated:YES];


        }else {
            [self.navigationController.view makeToast:[resultDict objectForKey:@"i"]];

        }
    }
}
- (IBAction)Cancel_btnClik:(UIButton *)sender {
    
    self.AlphaView.hidden = YES;
}
- (IBAction)CountryConfirm_btnClik:(UIButton *)sender {
    
    self.AlphaView.hidden = YES;
}

#pragma mark -
#pragma mark for delegates
#pragma mark -
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableDictionary *dic = [self.array objectAtIndex:indexPath.row] ;
    UITableViewCell *cell = nil;
    ResignTableViewCell *cell1 = [self.Country_tableView dequeueReusableCellWithIdentifier:@"ResignTableViewCell"];
    if (!cell1)
    {
        cell1 = [[ResignTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ResignTableViewCell"];
        cell1.backgroundColor = [UIColor whiteColor];
    }
    if (_selectPath == indexPath) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }else{
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    cell1.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell1 SetCellInfo:dic];
    
    cell = cell1;
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    int newRow = (int)[indexPath row];
    int oldRow = (int)(_selectPath != nil) ? (int)[_selectPath row]:-1;
    if (newRow != oldRow) {
        ResignTableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;
        newCell.spliteView.backgroundColor = BLUECOLOR;
        newCell.Country_name_label.textColor = BLUECOLOR;
        newCell.Country_code_label.textColor = BLUECOLOR;
        
        ResignTableViewCell *oldCell = [tableView cellForRowAtIndexPath:_selectPath];
        oldCell.accessoryType = UITableViewCellAccessoryNone;
        oldCell.spliteView.backgroundColor = [UIColor blackColor];
        oldCell.Country_name_label.textColor = [UIColor blackColor];
        oldCell.Country_code_label.textColor = [UIColor blackColor];
        
        _selectPath = [indexPath copy];
        
        
        
    }
    [self.Area_btn setTitle:[self.array objectAtIndex:indexPath.row][@"code"] forState:UIControlStateNormal];
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
        
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    // 输出点击的view的类名
    NSLog(@"%@", NSStringFromClass([touch.view class]));
    
    // 若为UITableViewCellContentView（即点击了tableViewCell），则不截获Touch事件
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return  YES;
}

- (IBAction)Area_btnClik:(UIButton *)sender {
    
    self.AlphaView.hidden = NO;
    

}

@end
